#!/bin/sh -ef
#
# Intentional, globbing disabled.
# shellcheck disable=2086

for f in pigz.o yarn.o try.o; do
    echo "$CC" -c -o "$f" "${f%%.o}.c" $CPPFLAGS -DNOZOPFLI $CFLAGS
    "$CC" -c -o "$f" "${f%%.o}.c" $CPPFLAGS -DNOZOPFLI $CFLAGS
done
echo "$CC" -static -o pigz pigz.o yarn.o try.o $CPPFLAGS $CFLAGS -lz $LDFLAGS
"$CC" -static -o pigz pigz.o yarn.o try.o $CPPFLAGS $CFLAGS -lz $LDFLAGS

mkdir -p \
    "$1/usr/bin" \
    "$1/usr/share/man/man1"

cp  -f pigz   "$1/usr/bin"
ln -sf pigz   "$1/usr/bin/gzip"
cp  -f pigz.1 "$1/usr/share/man/man1"
ln -sf pigz.1 "$1/usr/share/man/man1/gzip.1"
